package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LWaybilldetail;
import com.ruoyi.system.service.ILWaybilldetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 清运单明细Controller
 * 
 * @author zyb
 * @date 2022-01-02
 */
@RestController
@RequestMapping("/system/waybilldetail")
public class LWaybilldetailController extends BaseController
{
    @Autowired
    private ILWaybilldetailService lWaybilldetailService;

    /**
     * 查询清运单明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:waybilldetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(LWaybilldetail lWaybilldetail)
    {
        startPage();
        List<LWaybilldetail> list = lWaybilldetailService.selectLWaybilldetailList(lWaybilldetail);
        return getDataTable(list);
    }

    /**
     * 导出清运单明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:waybilldetail:export')")
    @Log(title = "清运单明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LWaybilldetail lWaybilldetail)
    {
        List<LWaybilldetail> list = lWaybilldetailService.selectLWaybilldetailList(lWaybilldetail);
        ExcelUtil<LWaybilldetail> util = new ExcelUtil<LWaybilldetail>(LWaybilldetail.class);
        util.exportExcel(response, list, "清运单明细数据");
    }

    /**
     * 获取清运单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:waybilldetail:query')")
    @GetMapping(value = "/{billid}")
    public AjaxResult getInfo(@PathVariable("billid") Long billid)
    {
        return AjaxResult.success(lWaybilldetailService.selectLWaybilldetailByBillid(billid));
    }

    /**
     * 新增清运单明细
     */
    @PreAuthorize("@ss.hasPermi('system:waybilldetail:add')")
    @Log(title = "清运单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LWaybilldetail lWaybilldetail)
    {
        return toAjax(lWaybilldetailService.insertLWaybilldetail(lWaybilldetail));
    }

    /**
     * 修改清运单明细
     */
    @PreAuthorize("@ss.hasPermi('system:waybilldetail:edit')")
    @Log(title = "清运单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LWaybilldetail lWaybilldetail)
    {
        return toAjax(lWaybilldetailService.updateLWaybilldetail(lWaybilldetail));
    }

    /**
     * 删除清运单明细
     */
    @PreAuthorize("@ss.hasPermi('system:waybilldetail:remove')")
    @Log(title = "清运单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{billids}")
    public AjaxResult remove(@PathVariable Long[] billids)
    {
        return toAjax(lWaybilldetailService.deleteLWaybilldetailByBillids(billids));
    }
}
